<nz-modal [(nzVisible)]="isVisible" [nzWidth]="modalWidth" (nzOnCancel)="onBack()" [nzStyle]="{'top': '50px'}">
  <div *nzModalTitle>{{ title }}</div>
  <ng-container *nzModalContent>
    <form [formGroup]="residentForm" (keydown.enter)="$event.preventDefault()">
      <nz-row [nzGutter]="10">
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="name" nzRequired>住户姓名</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入住户姓名'">
              <input nz-input formControlName="name" placeholder="请输入住户姓名" maxlength="64"/>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="phone" nzRequired>联系电话</nz-form-label>
            <nz-form-control [nzErrorTip]="'请输入联系电话'">
              <input nz-input formControlName="phone" placeholder="请输入联系电话" maxlength="20"/>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
      </nz-row>
      <nz-row [nzGutter]="10">
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="email">电子邮箱</nz-form-label>
            <nz-form-control>
              <input nz-input formControlName="email" placeholder="请输入电子邮箱" maxlength="100"/>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="buildingName" nzRequired>楼栋名称</nz-form-label>
            <nz-form-control [nzErrorTip]="'请选择楼栋名称'">
              <nz-input-group nzSearch [nzAddOnAfter]="buildingNameSuffixIconButton">
                <input nz-input formControlName="buildingName" placeholder="请选择楼栋名称" readonly />
              </nz-input-group>
              <ng-template #buildingNameSuffixIconButton>
                <button nz-button nzType="primary" nzSearch (click)="findBuilding()"><nz-icon nzType="search" /></button>
              </ng-template>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
      </nz-row>
      <nz-row [nzGutter]="10">
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="roomNumber">单元房号</nz-form-label>
            <nz-form-control>
              <nz-input-group nzSearch [nzAddOnAfter]="roomNumberSuffixIconButton">
                <input nz-input formControlName="roomNumber" placeholder="请选择单元房号" readonly />
              </nz-input-group>
              <ng-template #roomNumberSuffixIconButton>
                <button nz-button nzType="primary" nzSearch (click)="findRoom()"><nz-icon nzType="search" /></button>
              </ng-template>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="moveInDate">入驻日期</nz-form-label>
            <nz-form-control >
              <nz-date-picker formControlName="moveInDate" nzFormat="yyyy-MM-dd"></nz-date-picker>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
      </nz-row>
      <nz-row [nzGutter]="10">
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="moveOutDate">搬出日期</nz-form-label>
            <nz-form-control >
              <nz-date-picker formControlName="moveOutDate" nzFormat="yyyy-MM-dd"></nz-date-picker>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
        <nz-col [nzSpan]="12">
          <nz-form-item>
            <nz-form-label [nzSpan]="6" nzFor="type">住户类型</nz-form-label>
            <nz-form-control>
              <nz-select formControlName="type">
                <nz-option nzLabel="业主" [nzValue]="10"></nz-option>
                <nz-option nzLabel="成员" [nzValue]="20"></nz-option>
                <nz-option nzLabel="租户" [nzValue]="30"></nz-option>
              </nz-select>
            </nz-form-control>
          </nz-form-item>
        </nz-col>
      </nz-row>
    </form>
  </ng-container>
  <div *nzModalFooter>
    <div class="form-button-container">
      <button nz-button nzType="primary" (click)="onSave()" [nzLoading]="saveLoading">保存</button>
      <button nz-button nzType="default" (click)="onReset()" [nzLoading]="saveLoading">重置</button>
      <button nz-button nzType="default" (click)="onBack()">关闭</button>
    </div>
  </div>
</nz-modal>
<building-selector (buildingSelectedEvent)="handleBuildingSelectedEvent($event)"></building-selector>
<room-selector (roomSelectedEvent)="handleRoomSelectedEvent($event)"></room-selector>
